package cc.zy.base.hr.entity;

import cc.zy.base.common.converter.TimeConverter;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wuwenze.poi.annotation.Excel;
import com.wuwenze.poi.annotation.ExcelField;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 *  Entity
 *
 * @author pengfeng
 * @date: 2022/3/8 17:23
 */
@Data
@TableName("t_hr_trainning_batch")
@Excel("培训批次表")
public class TrainningBatch {

    /**
     * 主键
     */
    @TableId(value = "ID", type = IdType.AUTO)
    private Integer id;

    /**
     * 培训批次名称，不能有重复值，唯一索引
     */
    @TableField("TRAINNING_NAME")
    @ExcelField(value = "标签名称")
    private String trainningName;

    /**
     * 培训状态ID，0：草稿，1：定稿，默认：0
     */
    @TableId(value = "TRAINNING_STATUS_ID")
    private Integer trainningStatusId;

    /**
     * 培训状态，0：草稿，1：定稿，默认：0
     */
    @ExcelField(value = "培训状态")
    @TableField(exist = false)
    private String trainningStatusName;

    /**
     * 培训批次描述
     */
    @TableField("REMARK")
    private String remark;

    /**
     * 创建日期时间
     */
    @TableField("CREATE_DATE")
    @ExcelField(value = "创建时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "CTT")
    private Date createDate;

    /**
     * 创建用户ID
     */
    @TableField("CREATE_USER_ID")
    private Long createUserId;


    /**
     * 最后修改日期时间
     */
    @ExcelField(value = "最后一次修改时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "CTT")
    @TableField("LAST_MODIFY_DATE")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyDate;

    /**
     * 最后修改用户ID
     */
    @TableField("LAST_MODIFY_USER_ID")
    private Long lastModifyUserId;

    /**
     * 创建人名称
     */
    @ExcelField(value = "创建人")
    @TableField(exist = false)
    private String userName;

    /**
     * 更新人名称
     */
    @ExcelField(value = "更新人")
    @TableField(exist = false)
    private String updateUserName;

    public void setTrainningStatusId(Integer trainningStatusId) {
        this.trainningStatusId = trainningStatusId;
        if(trainningStatusId == 0){
            setTrainningStatusName("草稿");
        }else {
            setTrainningStatusName("定稿");
        }
    }
}
